package com.xiaoxing.gongqiju.mvp.ui.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.xiaoxing.gongqiju.R;
import com.xiaoxing.gongqiju.mvp.ui.entity.LiaoCheng_GongQiJu_GuiHuanCaoZuo;

import java.util.List;

//import me.jessyan.armscomponent.commonres.utils.GlideUtil;


public class LiaoCheng_GongQiJu_GuiHuanCaoZuoAdapter extends BaseQuickAdapter<LiaoCheng_GongQiJu_GuiHuanCaoZuo.DataBean, BaseViewHolder> {

    private Context mContext;
    private ILiaoCheng_GongQiJu_GuiHuanCaoZuoAdapter iLiaoCheng_gongQiJu_guiHuanCaoZuoAdapter;
    private String materialCodeMode;

    public LiaoCheng_GongQiJu_GuiHuanCaoZuoAdapter(Context context, @Nullable List<LiaoCheng_GongQiJu_GuiHuanCaoZuo.DataBean> data, ILiaoCheng_GongQiJu_GuiHuanCaoZuoAdapter iLiaoCheng_gongQiJu_guiHuanCaoZuoAdapter, String materialCodeMode) {
        super(R.layout.item_liao_cheng__gong_qi_ju__gui_huan_cao_zuo, data);
        this.mContext = context;
        this.materialCodeMode = materialCodeMode;
        this.iLiaoCheng_gongQiJu_guiHuanCaoZuoAdapter = iLiaoCheng_gongQiJu_guiHuanCaoZuoAdapter;
    }

    @Override
    protected void convert(BaseViewHolder helper, LiaoCheng_GongQiJu_GuiHuanCaoZuo.DataBean item) {
        //GlideUtil.loadImage(mContext,item.getImg(),helper.getView(R.id.img_head));
        try {
            helper.setText(R.id.tv_mid, "mid：" + item.getMid());
            helper.setText(R.id.tv_ying_gui_huan_shu_liang, "应归还数量：" + item.getOutNum());
            helper.setText(R.id.tv_dan_wei, "单位：" + item.getUnit());
            helper.setText(R.id.tv_gong_ju_ming_cheng, "工具名称：" + item.getMaterialtoolname());
            helper.setText(R.id.tv_na_huo_ren_xing_ming, "拿货人姓名：" + item.getRecevieusername());
            helper.setText(R.id.tv_na_huo_ren_dian_hua, "拿货人电话：" + item.getReceiveusephone());
            Button btn_sao_miao_er_wei_ma = helper.getView(R.id.btn_sao_miao_er_wei_ma);
            Button btn_gui_huan = helper.getView(R.id.btn_gui_huan);
            if (materialCodeMode.equals("2")) { //小工具
                btn_sao_miao_er_wei_ma.setVisibility(View.GONE);
                btn_gui_huan.setVisibility(View.VISIBLE);
                helper.setOnClickListener(R.id.btn_gui_huan, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        iLiaoCheng_gongQiJu_guiHuanCaoZuoAdapter.guiHuan(item);
                    }
                });
            } else if (materialCodeMode.equals("1")) {//大工具
                btn_sao_miao_er_wei_ma.setVisibility(View.VISIBLE);
                btn_gui_huan.setVisibility(View.GONE);
                helper.setOnClickListener(R.id.btn_sao_miao_er_wei_ma, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        iLiaoCheng_gongQiJu_guiHuanCaoZuoAdapter.saoMiaoErWerMa(item);
                    }
                });
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public interface ILiaoCheng_GongQiJu_GuiHuanCaoZuoAdapter {

        void saoMiaoErWerMa(LiaoCheng_GongQiJu_GuiHuanCaoZuo.DataBean item);

        void guiHuan(LiaoCheng_GongQiJu_GuiHuanCaoZuo.DataBean item);
    }

}
